package com.colin.service.impl;

import com.colin.mapper.GuestMapper;
import com.colin.pojo.Guest;
import com.colin.pojo.GuestList;
import com.colin.service.IGuestService;
import com.colin.utils.TimeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
@Service
public class GuestServiceImpl implements IGuestService {
    @Autowired
    GuestMapper guestMapper;

    @Override
    public List<GuestList> queryAllGuest(Map map){
        List<GuestList> guests = guestMapper.queryAllGuest(map);
        guests.forEach((e) -> {
            e.setCreateTime(TimeUtils.formatTime(Integer.parseInt(e.getCreateTime())));
        });
        return guests;
    }

    @Override
    public GuestList queryGuestById(Integer id) {
        GuestList guest = guestMapper.queryGuestById(id);
        guest.setCreateTime(TimeUtils.formatTime(Integer.parseInt(guest.getCreateTime())));
        return guest;
    }

    @Override
    public Integer addGuest(Integer uid , Guest guest) {
        guest.setUid(uid);
        return guestMapper.insert(guest);
    }
}
